package com.ncucoder.client.service.impl;

import com.ncucoder.client.mapper.OrderMapper;
import com.ncucoder.client.model.Order;
import com.ncucoder.client.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author <a href="https://www.ncucoder.com">hsowan</a>
 * @since 2019-01-19 07:59
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int saveOrUpdate(Order order) {
        return order.getId() != null ? orderMapper.updateById(order) : orderMapper.save(order);
    }

    @Override
    public Order getByMessageid(String messageId) {
        return orderMapper.getByMessageId(messageId);
    }
}
